/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package modelo;
import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.EmbeddedId;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.UniqueConstraint;
/**
 *
 * @author Elias Mendoza
 */
@Entity
@Table(name = "sustrato_nave",uniqueConstraints={@UniqueConstraint(columnNames={"id_sustrato","id_nave"})})
public class SustratoNave implements Serializable{

  @Id
  private int id;
  @JoinColumn(name="id_sustrato", referencedColumnName="id",nullable=false)
  @ManyToOne()
  private Sustrato sustratoFK;
  @JoinColumn(name="id_nave", referencedColumnName="id",nullable=false)
  @ManyToOne()
  private Nave naveFK;

  public SustratoNave() {
  }

  public int getId() {
    return id;
  }

  public void setId(int id) {
    this.id = id;
  }

  public Nave getNaveFK() {
    return naveFK;
  }

  public void setNaveFK(Nave naveFK) {
    this.naveFK = naveFK;
  }

  public Sustrato getSustratoFK() {
    return sustratoFK;
  }

  public void setSustratoFK(Sustrato sustratoFK) {
    this.sustratoFK = sustratoFK;
  }

  @Override
  public boolean equals(Object obj) {
    if (obj == null) {
      return false;
    }
    if (getClass() != obj.getClass()) {
      return false;
    }
    final SustratoNave other = (SustratoNave) obj;
    if (this.id != other.id) {
      return false;
    }
    if (this.sustratoFK != other.sustratoFK && (this.sustratoFK == null || !this.sustratoFK.equals(other.sustratoFK))) {
      return false;
    }
    if (this.naveFK != other.naveFK && (this.naveFK == null || !this.naveFK.equals(other.naveFK))) {
      return false;
    }
    return true;
  }

  @Override
  public int hashCode() {
    int hash = 7;
    hash = 53 * hash + this.id;
    hash = 53 * hash + (this.sustratoFK != null ? this.sustratoFK.hashCode() : 0);
    hash = 53 * hash + (this.naveFK != null ? this.naveFK.hashCode() : 0);
    return hash;
  }
  

}
